from config.all_paths import config_variable_path
from utils.file_handling.txt_handling import extract_txt
from config.global_variable import AI_XIAOWU


def AIDataProcessing(data, res):
    """
    AI数据处理
    """
    # 获取绑定的医生条数
    if data.get('case_name') == 'AI小梧相关数据统计':
        AI_Data = res.json()
        extract_txt(config_variable_path, str(AI_Data))

def AI_xiaowu(data, res):
    # AI小吴相关数据统计
    # 新增了2986个用户，新增了3172个宝贝，进小梧聊天的有1400个宝贝，717个宝贝点击了查看报告，68个宝贝主动提问过，大模型消耗了15块钱
    if data.get('case_name') == '中台-昨天':
        data = res.json().get('data')
        AI_XIAOWU['yesterday']['chatBabyNum'] = data['chatBabyNum']
        AI_XIAOWU['yesterday']['cardUserNum'] = data['cardUserNum']
        AI_XIAOWU['yesterday']['askQuestionBabyNum'] = data['askQuestionBabyNum']
        AI_XIAOWU['history']['repeatCenterUserNum'] = data['repeatCenterUserNum']
        AI_XIAOWU['history']['repeatConversationUserNum'] = data['repeatConversationUserNum']
    if data.get('case_name') == '中台-前天':
        data = res.json().get('data')
        AI_XIAOWU['beforeYesterday']['chatBabyNum'] = data['chatBabyNum']
        AI_XIAOWU['beforeYesterday']['cardUserNum'] = data['cardUserNum']
        AI_XIAOWU['beforeYesterday']['askQuestionBabyNum'] = data['askQuestionBabyNum']
    if data.get('case_name') == '中台-3天前':
        data = res.json().get('data')
        AI_XIAOWU['3DayAgo']['chatBabyNum'] = data['chatBabyNum']
        AI_XIAOWU['3DayAgo']['cardUserNum'] = data['cardUserNum']
        AI_XIAOWU['3DayAgo']['askQuestionBabyNum'] = data['askQuestionBabyNum']
    if data.get('case_name') == '中台-4天前':
        data = res.json().get('data')
        AI_XIAOWU['4DayAgo']['chatBabyNum'] = data['chatBabyNum']
        AI_XIAOWU['4DayAgo']['cardUserNum'] = data['cardUserNum']
        AI_XIAOWU['4DayAgo']['askQuestionBabyNum'] = data['askQuestionBabyNum']
    if data.get('case_name') == '中台-5天前':
        data = res.json().get('data')
        AI_XIAOWU['5DayAgo']['chatBabyNum'] = data['chatBabyNum']
        AI_XIAOWU['5DayAgo']['cardUserNum'] = data['cardUserNum']
        AI_XIAOWU['5DayAgo']['askQuestionBabyNum'] = data['askQuestionBabyNum']
    if data.get('case_name') == '中台-6天前':
        data = res.json().get('data')
        AI_XIAOWU['6DayAgo']['chatBabyNum'] = data['chatBabyNum']
        AI_XIAOWU['6DayAgo']['cardUserNum'] = data['cardUserNum']
        AI_XIAOWU['6DayAgo']['askQuestionBabyNum'] = data['askQuestionBabyNum']
    if data.get('case_name') == '中台-7天前':
        data = res.json().get('data')
        AI_XIAOWU['7DayAgo']['chatBabyNum'] = data['chatBabyNum']
        AI_XIAOWU['7DayAgo']['cardUserNum'] = data['cardUserNum']
        AI_XIAOWU['7DayAgo']['askQuestionBabyNum'] = data['askQuestionBabyNum']
    if data.get('case_name') == '梧桐-昨天':
        data = res.json().get('data')
        AI_XIAOWU['yesterday']['accountNum'] = data['accountNum']
        AI_XIAOWU['yesterday']['childrenNum'] = data['childrenNum']
    if data.get('case_name') == '梧桐-前天':
        data = res.json().get('data')
        AI_XIAOWU['beforeYesterday']['accountNum'] = data['accountNum']
        AI_XIAOWU['beforeYesterday']['childrenNum'] = data['childrenNum']
    if data.get('case_name') == '梧桐-3天前':
        data = res.json().get('data')
        AI_XIAOWU['3DayAgo']['accountNum'] = data['accountNum']
        AI_XIAOWU['3DayAgo']['childrenNum'] = data['childrenNum']
    if data.get('case_name') == '梧桐-4天前':
        data = res.json().get('data')
        AI_XIAOWU['4DayAgo']['accountNum'] = data['accountNum']
        AI_XIAOWU['4DayAgo']['childrenNum'] = data['childrenNum']
    if data.get('case_name') == '梧桐-5天前':
        data = res.json().get('data')
        AI_XIAOWU['5DayAgo']['accountNum'] = data['accountNum']
        AI_XIAOWU['5DayAgo']['childrenNum'] = data['childrenNum']
    if data.get('case_name') == '梧桐-6天前':
        data = res.json().get('data')
        AI_XIAOWU['6DayAgo']['accountNum'] = data['accountNum']
        AI_XIAOWU['6DayAgo']['childrenNum'] = data['childrenNum']
    if data.get('case_name') == '梧桐-7天前':
        data = res.json().get('data')
        AI_XIAOWU['7DayAgo']['accountNum'] = data['accountNum']
        AI_XIAOWU['7DayAgo']['childrenNum'] = data['childrenNum']


    extract_txt(config_variable_path, str(AI_XIAOWU))

